﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace dotnet_ef_admin.Migrations
{
    /// <inheritdoc />
    public partial class UpdatedModel : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_role_menu_Menus_MenuId",
                table: "role_menu");

            migrationBuilder.DropForeignKey(
                name: "FK_role_menu_Roles_RoleId",
                table: "role_menu");

            migrationBuilder.DropForeignKey(
                name: "FK_user_role_Roles_RoleId",
                table: "user_role");

            migrationBuilder.DropForeignKey(
                name: "FK_user_role_Users_UserId",
                table: "user_role");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Users",
                table: "Users");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Roles",
                table: "Roles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Menus",
                table: "Menus");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Dicts",
                table: "Dicts");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Depts",
                table: "Depts");

            migrationBuilder.RenameTable(
                name: "Users",
                newName: "user");

            migrationBuilder.RenameTable(
                name: "Roles",
                newName: "role");

            migrationBuilder.RenameTable(
                name: "Menus",
                newName: "menu");

            migrationBuilder.RenameTable(
                name: "Dicts",
                newName: "dict");

            migrationBuilder.RenameTable(
                name: "Depts",
                newName: "dept");

            migrationBuilder.AddPrimaryKey(
                name: "PK_user",
                table: "user",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_role",
                table: "role",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_menu",
                table: "menu",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_dict",
                table: "dict",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_dept",
                table: "dept",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_role_menu_menu_MenuId",
                table: "role_menu",
                column: "MenuId",
                principalTable: "menu",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_role_menu_role_RoleId",
                table: "role_menu",
                column: "RoleId",
                principalTable: "role",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_user_role_role_RoleId",
                table: "user_role",
                column: "RoleId",
                principalTable: "role",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_user_role_user_UserId",
                table: "user_role",
                column: "UserId",
                principalTable: "user",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_role_menu_menu_MenuId",
                table: "role_menu");

            migrationBuilder.DropForeignKey(
                name: "FK_role_menu_role_RoleId",
                table: "role_menu");

            migrationBuilder.DropForeignKey(
                name: "FK_user_role_role_RoleId",
                table: "user_role");

            migrationBuilder.DropForeignKey(
                name: "FK_user_role_user_UserId",
                table: "user_role");

            migrationBuilder.DropPrimaryKey(
                name: "PK_user",
                table: "user");

            migrationBuilder.DropPrimaryKey(
                name: "PK_role",
                table: "role");

            migrationBuilder.DropPrimaryKey(
                name: "PK_menu",
                table: "menu");

            migrationBuilder.DropPrimaryKey(
                name: "PK_dict",
                table: "dict");

            migrationBuilder.DropPrimaryKey(
                name: "PK_dept",
                table: "dept");

            migrationBuilder.RenameTable(
                name: "user",
                newName: "Users");

            migrationBuilder.RenameTable(
                name: "role",
                newName: "Roles");

            migrationBuilder.RenameTable(
                name: "menu",
                newName: "Menus");

            migrationBuilder.RenameTable(
                name: "dict",
                newName: "Dicts");

            migrationBuilder.RenameTable(
                name: "dept",
                newName: "Depts");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Users",
                table: "Users",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Roles",
                table: "Roles",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Menus",
                table: "Menus",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Dicts",
                table: "Dicts",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Depts",
                table: "Depts",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_role_menu_Menus_MenuId",
                table: "role_menu",
                column: "MenuId",
                principalTable: "Menus",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_role_menu_Roles_RoleId",
                table: "role_menu",
                column: "RoleId",
                principalTable: "Roles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_user_role_Roles_RoleId",
                table: "user_role",
                column: "RoleId",
                principalTable: "Roles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_user_role_Users_UserId",
                table: "user_role",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
